Skip to content

docs: add guidance on choosing what to lazy load - #102472

Draft
icyJoseph wants to merge 2 commits into
canaryfrom
docs/lazy-loading-use-cases
Draft

icyJoseph wants to merge 2 commits into
canaryfrom
docs/lazy-loading-use-cases

Conversation

@icyJoseph

Copy link
Copy Markdown
Member

What?

Follow-up to #102401. Adds a way to choose between prerendering, use(browser()), and next/dynamic when you land on either guide.

Lazy Loading guide:

  • New "Choosing what to lazy load" section with a table that maps common situations to an approach.
  • "Skipping SSR" now says what ssr: false is for: lazy load a component and keep its module out of the server render.
  • New "Loading on interaction" section: what the loading placeholder does on a click, and how to show the component as soon as its code loads by updating state in a transition.
  • New "Preloading before interaction" section: a hidden <Activity>, or preloading on hover and focus through a shared loader.

Single-Page Applications guide:

  • A short table at the top of "Rendering components only in the browser" for choosing between use(browser()) and next/dynamic with ssr: false.

Why?

The two APIs were described, but the decision between them was spread across paragraphs, and nothing covered components that load after an interaction. That case has behavior worth knowing: with a loading placeholder the component appears with React's next batch of suspended content, even when its code is already loaded.

Verification

Measured in a repro app on a production build (Next.js 16.4.6, cacheComponents: true, Turbopack, headless Chrome). Time from click to content, with a 150ms delay on scripts requested after the click:

Setup Content on page
Static import 1ms
next/dynamic with loading 303ms
next/dynamic without loading, in a transition 155ms
next/dynamic without loading, no transition, inside a page <Suspense> 308ms, section replaced by the boundary's fallback
Hidden <Activity> around next/dynamic 1ms
Preload on hover through a shared loader with React.lazy, click 300ms later 29ms
Preload on focus, Enter 300ms later 4ms

Also checked:

  • A route that doesn't render a component doesn't load its code.
  • A module that reads window at import fails next build behind use(browser()) and builds with next/dynamic and ssr: false.
  • Not run: Pages Router. The new sections are inside the App Router block of the shared guide.

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Tests Passed

Commit: 7088f9f
View workflow run

@github-actions github-actions Bot added created-by: Next.js team PRs by the Next.js team. Documentation Related to Next.js' official documentation. labels Nov 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

created-by: Next.js team PRs by the Next.js team. Documentation Related to Next.js' official documentation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant